<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 小西瓜 <751707632@qq.com.com>
// +----------------------------------------------------------------------
namespace app\fowl\model;

use think\Model;               
use tree\Tree;
use think\Db;
use app\fowl\model\ImsStramingLiveModel;

class ImsStramingGameModel extends Model
{
    /**
     * 查询PK资讯
     * @param array $where 查询条件
     * @param string $order 查询顺序
     * @return array
     */
    public function gameInfo($where=array(), $order='')
    {
        $info = $this->alias('sj')->field('')->where($where)->order($order)->select()->toArray();
        foreach ( $info as $key => $val ) {
            // 获取直播信息
            $stramingModel = new ImsStramingLiveModel();
           if ($val['initiator_vm_id']) $info['initiator'] = $stramingModel->stramingInfo(['vm.id'=>$val['initiator_vm_id']]);
           if ($val['party_vm_id']) $info['party'] = $stramingModel->stramingInfo(['vm.id'=>$val['party_vm_id']]);
        }

        return $info;
    }
}